spaghetti code(“意大利面式代码”):指结构杂乱、耦合严重、逻辑缠绕、缺乏清晰模块划分的代码,阅读和维护困难,修改时容易“牵一发而动全身”。(也常被视为一种典型的 code smell 代码坏味道。)
/spəˈɡɛti koʊd/
The project became spaghetti code after years of rushed fixes.
多年来不断仓促修补后,这个项目变成了“意大利面式代码”。
Without tests and clear boundaries, new features kept weaving into the old logic until the system turned into spaghetti code that nobody dared to touch.
缺少测试和清晰边界时,新功能不断缠进旧逻辑里,系统最终变成谁都不敢碰的“意大利面式代码”。
这是软件工程里的比喻说法:把代码的控制流与依赖关系比作一盘纠缠在一起的意大利面,线条交错、难以理清。该表达在 20 世纪后期逐渐流行于程序员社群,用来批评缺乏设计与重构的代码质量问题。